﻿using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Runtime.CompilerServices;
using Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using SnowTech.SmartTms.Repository.Domain;

namespace SnowTech.SmartTms.App.TmsOilCostManager.Request
{
    public class AddOrUpdateOilCostReq
    {
        /// <summary>
        /// 主键Id
        /// </summary>
        [Required]
        [StringLength(50)]
        public string Id { get; set; }
        /// <summary>
        /// 经办人
        /// </summary>
        [Required]
        [StringLength(50)]
        public string Operator { get; set; }
        /// <summary>
        /// 车牌号
        /// </summary>
        [Required]
        [StringLength(50)]
        public string PlateNumber { get; set; }
        /// <summary>
        /// 加油费用/元
        /// </summary>
        [Required]
        [Range(typeof(decimal), "0.00", "99999999.99")]
        public decimal OilCost { get; set; }
        /// <summary>
        /// 加油量/L
        /// </summary>
        [Required]
        [Range(typeof(decimal), "0.00", "999.99")]
        public decimal FuelQuantity { get; set; }
        /// <summary>
        /// 起始公里数
        /// </summary>
        [Required]
        public int Mileage { get; set; }
        /// <summary>
        /// 支付方式
        /// </summary>
        [Required]
        public int PaymentMethod { get; set; }
        /// <summary>
        /// 备注
        /// </summary>
        [StringLength(255)]
        public string Remarks { get; set; }
        /// <summary>
        /// 使用对象关系映射隐式转换
        /// </summary>
        /// <param name="oilCost"></param>
        public static implicit operator AddOrUpdateOilCostReq(TmsOilCost oilCost)
        {
            return oilCost.MapTo<AddOrUpdateOilCostReq>();
        }

        public static implicit operator TmsOilCost(AddOrUpdateOilCostReq view)
        {
            return view.MapTo<TmsOilCost>();
        }
    }
}
